package com.isoft.domain;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.validation.constraints.Min;

import lombok.Data;

/**
 * Created by yigeyanse on 2017/6/16.
 */
@Data
@Entity
@Table(name = "sys_user")
public class SysUser implements Serializable{

	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy= GenerationType.AUTO)
    private Integer sysUserId;
	
	@Column(unique = true)  
    private String sysUserName;
	
	@Column
	private String sysUserPwd;
	
	@Column
	@Min(value = 18,message = "未成年少女禁止入内！")
    private Integer sysUserAge;
    
    @ManyToMany(fetch = FetchType.EAGER) // 立即从数据库中进行加载数据  
    @JoinTable(name = "SysUserRole", joinColumns = { @JoinColumn(name = "userId") }, inverseJoinColumns = {  
            @JoinColumn(name = "roleId") })     
    private List<SysRole> roleList;// 一个用户具有多个角色  

	@Override
	public String toString() {
		return "SysUser [sysUserId=" + sysUserId + ", sysUserName=" + sysUserName + ", sysUserPwd=" + sysUserPwd + ", sysUserAge=" + sysUserAge + "]";
	}

 
}
